﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;

namespace _048
{
    internal class Program
    {
        static void Swap<T>(ref T lhs,ref T rhs)
        {
            T temp;
            temp = lhs;
            lhs = rhs;
            rhs = temp;
        }
        static void Main(string[] args)
        {
            int a, b;
            char c, d;
            a = 10;
            b = 20;
            c = 'I';
            d = 'V';

            //在交换之前显示值
            Console.WriteLine("调用swap之前的int值为：");
            Console.WriteLine("a={0},b={1}",a,b);
            Console.WriteLine("调用swap之前的char值为：");
            Console.WriteLine("c={0},d={1}",c,d);

            //调用swap
            Swap<int>(ref a, ref b);
            Swap<char>(ref c, ref d);

            //在交换之后显示值
            Console.WriteLine("调用swap之后的int值：");
            Console.WriteLine("a={0},b={1}",a,b);
            Console.WriteLine("调用swpa之后的char值：");
            Console.WriteLine("c={0},d={1}",c,d);
            Console.ReadKey();

        }
    }
}
